package com.huawei.appgallery.purchasehistory.ui.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.huawei.appgallery.foundation.store.bean.detail.DetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appgallery.foundation.ui.framework.widget.NodataWarnLayout;
import com.huawei.appgallery.purchasehistory.api.AppTracesListFragmentProtocol;
import com.huawei.appgallery.purchasehistory.api.AppTracesListFragmentProtocol.Request;
import com.huawei.appgallery.purchasehistory.impl.PurchaseHistoryManager;
import java.util.List;
import o.cfv;
import o.csp;
import o.cst.h;
import o.cta;
import o.ctj;
import o.ctk;
import o.ctm;
import o.ctn;
import o.ctp;
import o.ctr;
import o.dgm;
import o.dof;
import o.CollectCheck;

public class FamilyShareAppsFragment extends AppListFragment<AppTracesListFragmentProtocol> implements ctn, ctk, ctp {
    private boolean ˊ = false;
    private Activity ॱॱ;
    private String ᐝ = "";
    private boolean ﾞ = false;

    class d implements Runnable {
        final /* synthetic */ FamilyShareAppsFragment ˎ;

        private d(FamilyShareAppsFragment familyShareAppsFragment) {
            this.ˎ = familyShareAppsFragment;
        }

        public void run() {
            if (this.ˎ.י != null) {
                ctr.ˋ(this.ˎ.י);
                this.ˎ.י.ͺ();
            }
            ctr.ˏ(this.ˎ.ॱॱ);
            if (!this.ˎ.י()) {
                if (this.ˎ.ߴ == null || this.ˎ.ͺˎ == null) {
                    csp.ˏ.ˋ("AppListFragment", "no data");
                    return;
                }
                this.ˎ.ߴ.setWarnTextOne(h.ॱˊ);
                this.ˎ.ͺˎ.setEmptyView(this.ˎ.ߴ);
            }
        }
    }

    public void ˏ(Bundle bundle) {
        AppTracesListFragmentProtocol appTracesListFragmentProtocol = (AppTracesListFragmentProtocol) ˆ();
        if (appTracesListFragmentProtocol == null || appTracesListFragmentProtocol.ॱ() == null) {
            csp.ˏ.ˊ("AppListFragment", "onCreate AppTracesListFragmentProtocol is null or Request is null!");
        } else {
            this.ˊ = ((Request) appTracesListFragmentProtocol.ॱ()).ˋᐝ();
            this.ᐝ = ((Request) appTracesListFragmentProtocol.ॱ()).ˍ();
        }
        super.ˏ(bundle);
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.ॱॱ = ॱˋ();
        if (this.ॱॱ instanceof ctm) {
            ((ctm) this.ॱॱ).ˎ(this);
        }
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        this.ͺˎ.ˊॱ().setVisibility(8);
        return ˋ;
    }

    public void ॱ(NodataWarnLayout nodataWarnLayout) {
        if (nodataWarnLayout != null) {
            nodataWarnLayout.setWarnImage(b.ʼ);
            nodataWarnLayout.setWarnTextOne(h.ˏॱ);
            nodataWarnLayout.setViewVisible(e.WARN_BTN, 8);
            nodataWarnLayout.setViewVisible(e.WARN_TEXTTWO, 8);
        }
    }

    public cfv ˏ(String str, String str2, int i) {
        cfv ˎ = cta.ˎ(str2, i);
        ˎ.setServiceType_(dgm.ˎ(this.ॱॱ));
        ˎ.ˏ("familymembershare|" + this.ᐝ);
        ˎ.ˊॱ(this.ᐝ);
        return ˎ;
    }

    public void ˊʻ() {
    }

    public void ٴ() {
        PurchaseHistoryManager.getHelper().ˊ(this.ॱॱ, this.ᐝ, this.ˊ);
    }

    public void ˎˎ() {
        if (this.ॱॱ instanceof ctm) {
            ((ctm) this.ॱॱ).ˊ(this);
        }
        super.ˎˎ();
    }

    public void ˌ() {
        super.ˌ();
        this.ﾞ = false;
    }

    public void ˋᐝ() {
        super.ˋᐝ();
        this.ﾞ = true;
    }

    public void ˎ(String str) {
        if (!dof.ˎ(str, "android.intent.action.PACKAGE_ADDED")) {
            this.ˏ = 1;
            this.י.ॱॱ();
            this.י.ˊ(true);
            csp.ˏ.ˋ("AppListFragment", "trace has changed,get the new data from network!!!");
            ʿˊ();
        } else if (this.ˊ) {
            new Handler().postDelayed(new d(), 100);
        } else if (this.י == null) {
            csp.ˏ.ˋ("AppListFragment", "null == provider");
        } else {
            ctr.ॱ(this.ॱॱ, ctr.ˏ(this.י), true);
        }
    }

    public boolean י() {
        return this.י == null || this.י.ˊॱ() != 0;
    }

    public boolean ˊ(TaskFragment taskFragment, TaskFragment.b bVar) {
        DetailResponse detailResponse = (DetailResponse) bVar.ˋ;
        List ᐝॱ = detailResponse.ᐝॱ();
        if (!ॱ(detailResponse.getResponseCode(), detailResponse.getRtnCode_())) {
            return super.ˊ(taskFragment, bVar);
        }
        boolean z = !CollectCheck.isEmpty(ᐝॱ);
        ctr.ˋ(ᐝॱ, true, this.ˊ);
        ctr.ˎ(this.ॱॱ, detailResponse, true);
        if (this.ˏ == 1 && this.ﾞ) {
            this.ͺˎ.setAdapter(this.ـॱ);
        }
        if (z && this.י.ˏॱ() && this.ˊ) {
            this.ߴ.setWarnTextOne(h.ॱˊ);
        }
        super.ˊ(taskFragment, bVar);
        this.ˏ = ((cfv) bVar.ˊ).ˏ() + 1;
        ctr.ˏ(this.ॱॱ);
        if (this.ˏ == 2 && this.ͺˎ != null) {
            this.ͺˎ.ˊॱ().setVisibility(0);
        }
        if (this.י.ˊॱ() != 0 || !this.י.ᐝ()) {
            return false;
        }
        csp.ˏ.ˋ("AppListFragment", " auto load next page nextPageNum=" + this.ˏ);
        ʿˊ();
        return false;
    }

    public void ʼᐝ() {
        super.ʼᐝ();
        csp.ˏ.ˋ("AppListFragment", " onLoadingRetry");
        if (this.ॱॱ instanceof ctj) {
            ((ctj) this.ॱॱ).ˉ();
        }
    }

    public void ॱʾ() {
        ʿˊ();
    }

    public void ʿˊ() {
        super.ʿˊ();
        csp.ˏ.ˋ("AppListFragment", "execute");
    }
}
